< previous page page_443 next page >

Page 443
Use Table 11.3 as a guide for adding the following menu items to the CompanyMaster menu.
Table 11.3. Added menu items for the CompanyMaster main menu.
CaptionMenu
&GraphsmnuGraphs
Sales by &RegionmnuGraphsItem(0)
Sales by &MonthmnuGraphsItem(1)
Sales by &CustomermnuGraphsItem(2)

Now you need to add code to the form to make the calls to the DataGraph object. For your first graph, you want to create a pie chart showing the total year's sales by region. The fields you have to work with in the SalesData table are CompanyName, Year, Month, Amount, and Region. The database contains records for each month for each customer, along with budget values for the year. These budget records are stored with a CompanyName of Budget.
To get the total customer sales by region, you use the following SQL SELECT statement:
SELECT Region, SUM(Amount) AS SalesTotal
   FROM SalesData
   WHERE CompanyName<>'Budget'
   GROUP BY Region
This is the SQL statement you use to generate the Snapshot object that is passed to the graph library. Place Listing 11.29 in the mnuGraphsItem Click event.
Type.gifListing 11.29. Adding the code to the mnuGraphsItem_Click event.
Private Sub mnuGraphsItem_Click(Index As Integer)
    '
    ' handle graph menu requests
    '
    Dim objDG As New DataGraph
    Dim strSQL As String
    '
    Select Case Index
        Case 0 ' sales by region
            '
            strSQL = "SELECT Region, SUM(Amount) AS SalesTotal FROM "
            strSQL = strSQL & "SalesData WHERE CompanyName<>'Budget' GROUP BY
            arrow.gifRegion"
            '
continues

 
< previous page page_443 next page >

If you like this book, buy it!